package part05_原型模式.p03_深拷贝;

/**
 * @ClassName: Sheep02
 * @Author: AllenSun
 * @Date: 2019/12/6 20:46
 */
public class Sheep03 implements Cloneable{
    private String name;
    private int age;
    private String coler;
    private String address="蒙古羊";
    public Sheep03 friend;

    public Sheep03(String name, int age, String coler) {
        this.name = name;
        this.age = age;
        this.coler = coler;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getColer() {
        return coler;
    }

    public void setColer(String coler) {
        this.coler = coler;
    }

    @Override
    public String toString() {
        return "Sheep02{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", coler='" + coler + '\'' +
                '}';
    }

    //重写Cloneable接口里面的clone方法
    //浅拷贝，使用默认的clone方法
    @Override
    protected Object clone() {
        Sheep03 sheep02=null;
        try {
            sheep02= (Sheep03) super.clone();
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
        return sheep02;
    }
}
